package org.luckyjourney.mapper.booking;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.luckyjourney.entity.booking.Orders;
import org.luckyjourney.entity.booking.Refunds;
import org.luckyjourney.entity.booking.dto.OrdersDTO;
import org.luckyjourney.entity.booking.vo.OrderVO;
import org.luckyjourney.entity.booking.vo.RefundsVO;

import java.time.LocalDateTime;
import java.util.List;

@Mapper
public interface OrdersMapper {
    void insert(Orders orders);

    void update(Orders orders);

    OrderVO select(Long id);

    void delect(Long id);

    List<OrderVO> selectPage(OrdersDTO ordersDTO);

    /**
     * 根据订单号和用户id查询订单
     *
     * @param
     * @param ordersDTO
     */
    //
    Orders getByNumberAndUserId(OrdersDTO ordersDTO);

    Orders selectOrdersNumber(String ordersNumber);

    int insertRefunds(Refunds refunds);

    List<OrderVO> selectCounts(OrdersDTO ordersDTO);

    /**
     * 根据状态和过期时间查询
     *
     * @param status 订单状态
     * @param time   拿订单时间和此时间比较
     *               订单时间 > 此时间 => 没到期
     *               订单时间 < 此时间 => 到期了,需要改状态
     * @return
     */
    List<Orders> findByStatusAndOrdertimeLT(@Param("status") Integer status, @Param("time") LocalDateTime time);


    RefundsVO selectRefunddetails(Refunds refunds);

    Boolean updateRefund(Refunds refunds);

    /**
     * 删除已经申请过的订单
     *
     * @param refund
     */
    int delectRefunds(Refunds refund);
}
